package com.renting.common.security;

import com.renting.modules.sys.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.logging.LogRecord;

@WebFilter(filterName = "F1",urlPatterns = "*")
@Configuration
public class LogFilter implements Filter {

    @Autowired
    LogService logService;

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        logService.save((HttpServletRequest) request);
        chain.doFilter(request, response);

    }

    @Override
    public void destroy() {

    }
}
